﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    mc:Ignorable="d"
                    xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
                    xmlns:System="clr-namespace:System;assembly=mscorlib"
                    xmlns:Fluent="clr-namespace:Fluent"
                    xmlns:Behaviours="clr-namespace:Fluent.Metro.Behaviours">
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <Fluent:IconConverter x:Key="IconConvert"/>
  <BitmapImage x:Key="ImageCaptionButtonClose" UriSource="pack://application:,,,/Fluent;component/Themes/Office2010/Images/CaptionButtonClose.png" PresentationOptions:Freeze="True"/>	
    <BitmapImage x:Key="ImageCaptionButtonMinimize" UriSource="pack://application:,,,/Fluent;component/Themes/Office2010/Images/CaptionButtonMinimize.png" PresentationOptions:Freeze="True"/>
    <BitmapImage x:Key="ImageCaptionButtonNormalize" UriSource="pack://application:,,,/Fluent;component/Themes/Office2010/Images/CaptionButtonNormalize.png" PresentationOptions:Freeze="True"/>
    <BitmapImage x:Key="ImageCaptionButtonMaximize" UriSource="pack://application:,,,/Fluent;component/Themes/Office2010/Images/CaptionButtonMaximize.png" PresentationOptions:Freeze="True"/>
  <Style TargetType="{x:Type ResizeGrip}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ResizeGrip}">
          <Grid Width="11" Height="11" Background="Transparent">
            <Grid Width="3" Height="3" HorizontalAlignment="Right" VerticalAlignment="Bottom">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBackBrush}" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFrontBrush}" HorizontalAlignment="Left" VerticalAlignment="Top"/>              
            </Grid>
            <Grid Width="3" Height="3" HorizontalAlignment="Center" VerticalAlignment="Bottom">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBackBrush}" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFrontBrush}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
            </Grid>
            <Grid Width="3" Height="3" HorizontalAlignment="Left" VerticalAlignment="Bottom">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBackBrush}" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFrontBrush}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
            </Grid>
            <Grid Width="3" Height="3" HorizontalAlignment="Right" VerticalAlignment="Center">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBackBrush}" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFrontBrush}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
            </Grid>
            <Grid Width="3" Height="3" HorizontalAlignment="Center" VerticalAlignment="Center">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBackBrush}" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFrontBrush}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
            </Grid>
            <Grid Width="3" Height="3" HorizontalAlignment="Right" VerticalAlignment="Top">
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripBackBrush}" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
              <Rectangle Width="2" Height="2" Fill="{DynamicResource ResizeGripFrontBrush}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
            </Grid>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <ControlTemplate x:Key="DwmRibbonWindowControlTemplate" TargetType="{x:Type Fluent:RibbonWindow}">
    <Grid>
      <AdornerDecorator x:Name="adornerDecorator" Margin="0">
        <Grid x:Name="PART_MainGrid" Margin="0" Background="{DynamicResource TransparentBrush}" VerticalAlignment="Stretch">
          <Grid x:Name="PART_TitleBar" Margin="{TemplateBinding ResizeBorderThickness}" VerticalAlignment="Top" Height="{TemplateBinding CaptionHeight}" Background="{DynamicResource TransparentBrush}" IsHitTestVisible="True"/>
          <Rectangle x:Name="rectangle" Stroke="{x:Null}" HorizontalAlignment="Left" Width="35" StrokeThickness="0" Margin="15,0,0,1" VerticalAlignment="Top" Height="50" IsHitTestVisible="False" Fill="{DynamicResource RibbonTabControlTopGradientLeftBrush}" SnapsToDevicePixels="True"/>
          <Rectangle x:Name="rectangle1" Stroke="{x:Null}" HorizontalAlignment="Right" Width="35" StrokeThickness="0" Margin="0,0,15.1,1" Height="50" VerticalAlignment="Top" IsHitTestVisible="False" Fill="{DynamicResource RibbonTabControlTopGradientRightBrush}" SnapsToDevicePixels="True"/>
          <Rectangle x:Name="rectangle2" Stroke="{x:Null}" HorizontalAlignment="Stretch" Width="Auto" StrokeThickness="0" Height="50" Margin="50,0,50,1" VerticalAlignment="Top" IsHitTestVisible="False" Fill="{DynamicResource RibbonTabControlTopGradientCenterBrush}" SnapsToDevicePixels="True"/>

          <Grid x:Name="grid" Background="{TemplateBinding Background}" Margin="{TemplateBinding GlassBorderThickness}"/>
          <StackPanel Background="Transparent" x:Name="PART_IconImage" Margin="8,7,8,8" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top">
            <Image x:Name="PART_Icon" Height="16" HorizontalAlignment="Left" VerticalAlignment="Top" Source="{Binding Icon, Converter={StaticResource IconConvert}, RelativeSource={RelativeSource TemplatedParent}}" Width="16" SnapsToDevicePixels="True"
                               Visibility="{TemplateBinding IsIconVisible, Converter={StaticResource BooleanToVisibilityConverter}}" />
          </StackPanel>
          <ContentPresenter Margin="8,1,8,8" x:Name="contentPresenter"/>
          <ResizeGrip x:Name="PART_ResizeGrip" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right"
                VerticalAlignment="Bottom" Focusable="False" Margin="0,0,5.5,5.5" Background="Transparent"
                Visibility="Collapsed"/>
        </Grid>
      </AdornerDecorator>
    </Grid>
    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
          <Condition Property="WindowState" Value="Normal"/>
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" TargetName="PART_ResizeGrip" Value="Visible"/> 
      </MultiTrigger>
      <Trigger Property="WindowState" Value="Maximized">
        <Setter Property="Margin" TargetName="PART_IconImage" Value="0,4,0,0"/>
        <Setter Property="Margin" TargetName="adornerDecorator" Value="0"/>
        <Setter Property="Margin" TargetName="contentPresenter" Value="0,0,0,0"/>
        <Setter Property="Margin" TargetName="rectangle" Value="15,4,0,1"/>
        <Setter Property="Margin" TargetName="rectangle1" Value="0,4,15.1,1"/>
        <Setter Property="Margin" TargetName="rectangle2" Value="50,4,50,1"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <ControlTemplate x:Key="NonDwmRibbonWindowControlTemplate" TargetType="{x:Type Fluent:RibbonWindow}">
    <Grid>
        <Grid>
      <AdornerDecorator x:Name="adornerDecorator" VerticalAlignment="Stretch">
        <Grid>
          <Border x:Name="PART_SizeBorder" BorderBrush="{DynamicResource WindowOutterBorderBrush}" BorderThickness="1,1,1,1" CornerRadius="8.5" Opacity="1" Background="{DynamicResource WindowOutterBackgroundBrush}">
            <Border x:Name="border2" BorderBrush="{DynamicResource WindowInnerBorderBrush}" BorderThickness="1,1,1,1" CornerRadius="7,7,7,7" Background="{x:Null}" Opacity="1">
              <Border x:Name="border3" BorderBrush="{x:Null}" BorderThickness="0,0,0,0" Opacity="1" CornerRadius="6" VerticalAlignment="Top" Height="50" Background="{DynamicResource WindowInnerBackgroundBrush}"/>
            </Border>
          </Border>
          <Grid x:Name="PART_MainGrid" Margin="0" Background="#00FFFFFF">
            <Grid x:Name="PART_TitleBar" Margin="{TemplateBinding ResizeBorderThickness}" VerticalAlignment="Top" Height="{TemplateBinding CaptionHeight}" Background="#00FFFFFF" IsHitTestVisible="True"/>
            <StackPanel Background="Transparent" x:Name="PART_IconImage" Margin="8,7,0,0" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top">
              <Image x:Name="PART_Icon" Height="16" HorizontalAlignment="Left" VerticalAlignment="Top" Source="{Binding Icon, Converter={StaticResource IconConvert}, RelativeSource={RelativeSource TemplatedParent}}" Width="16" SnapsToDevicePixels="True" Stretch="Uniform"
                                   Visibility="{TemplateBinding IsIconVisible, Converter={StaticResource BooleanToVisibilityConverter}}" />
            </StackPanel>
            <ContentPresenter Content="{Binding WindowCommands, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:RibbonWindow}}}"
                                x:Name="PART_WindowCommands"
                                Margin="0,2,8,0"
                                Panel.ZIndex="1"
                                Grid.RowSpan="2"
                                VerticalAlignment="Top"
                                HorizontalAlignment="Right"
                                Height="{Binding Path=(Fluent:RibbonProperties.TitleBarHeight), RelativeSource={RelativeSource Self}}" />
            <Border x:Name="border4" Margin="8,50,8,8" >
              <Border x:Name="border1" Height="Auto" BorderThickness="1,1,1,1" BorderBrush="{DynamicResource WindowContentBorderBrush}" Margin="-1">
                <Grid x:Name="grid" Background="{TemplateBinding Background}"/>
              </Border>
            </Border>
            <ContentPresenter Margin="8,1,8,8" x:Name="contentPresenter"/>
            <ResizeGrip x:Name="PART_ResizeGrip" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right"
        VerticalAlignment="Bottom" Focusable="False" Margin="0,0,5.5,5.5"
        Cursor="SizeNWSE" Visibility="Collapsed"/>
          </Grid>
        </Grid>
      </AdornerDecorator>
        </Grid>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="IsActive" Value="False">
        <Setter Property="Background" TargetName="PART_SizeBorder" Value="{DynamicResource WindowInactiveOutterBackgroundBrush}"/>
        <Setter Property="Background" TargetName="border3" Value="{DynamicResource WindowInactiveInnerBackgroundBrush}"/>
      </Trigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
          <Condition Property="WindowState" Value="Normal"/>
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" TargetName="PART_ResizeGrip" Value="Visible"/>
      </MultiTrigger>
      <Trigger Property="WindowState" Value="Maximized">
        <Setter Property="Margin" TargetName="PART_IconImage" Value="0,4,0,0"/>
        <Setter Property="BorderThickness" TargetName="PART_SizeBorder" Value="0,0,0,0"/>
        <Setter Property="CornerRadius" TargetName="PART_SizeBorder" Value="0,0,0,0"/>
        <Setter Property="BorderThickness" TargetName="border2" Value="0,0,0,0"/>
        <Setter Property="CornerRadius" TargetName="border2" Value="0,0,0,0"/>
        <Setter Property="Margin" TargetName="PART_WindowCommands" Value="0,0,0,0"/>
        <Setter Property="Margin" TargetName="contentPresenter" Value="0,0,0,0"/>
        <Setter Property="Height" TargetName="border2" Value="54"/>
                <Setter Property="Margin"
                        TargetName="border4"
                        Value="0,50,0,0" />
            </Trigger>
        <Trigger Property="IsCollapsed"
                    Value="True">
            <Setter Property="Margin"
                    TargetName="border4"
                    Value="8,30,8,8" />
        </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="CaptionButtonStyle" TargetType="{x:Type Button}">
    <Setter Property="Width" Value="35"/>
    <Setter Property="Height" Value="19"/>
    <Setter Property="Template" Value="{DynamicResource CaptionButtonControlTemplate}"/>
        <Setter Property="Focusable"
                Value="False" />
    </Style>
  <ControlTemplate x:Key="CaptionButtonControlTemplate" TargetType="{x:Type Button}">
    <Grid Background="Transparent">
      <Border x:Name="hoverBorder" Margin="0" BorderBrush="{DynamicResource CaptionButtonHoverOutterBorderBrush}" BorderThickness="1" CornerRadius="2" Visibility="Collapsed">
        <Border x:Name="hoverBorderInner" BorderBrush="{DynamicResource CaptionButtonHoverInnerBorderBrush}" BorderThickness="1" CornerRadius="1" Background="{DynamicResource CaptionButtonHoverInnerBackgroundBrush}"/>
      </Border>
      <Border x:Name="pressedBorder" Margin="0" BorderBrush="{DynamicResource CaptionButtonPressedOutterBorderBrush}" BorderThickness="1" CornerRadius="2" Visibility="Collapsed">
        <Border x:Name="pressedBorderInner" BorderBrush="{DynamicResource CaptionButtonPressedInnerBorderBrush}" BorderThickness="1" CornerRadius="1" Background="{DynamicResource CaptionButtonPressedInnerBackgroundBrush}"/>
      </Border>
      <ContentPresenter Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Grid>
    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True"/>
          <Condition Property="IsPressed" Value="False"/>
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" TargetName="hoverBorder" Value="Visible"/>
      </MultiTrigger>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="Visibility" TargetName="pressedBorder" Value="Visible"/>
      </Trigger>
      <Trigger Property="Background" Value="Red">
        <Setter Property="BorderBrush" TargetName="hoverBorder" Value="{DynamicResource CaptionButtonCloseHoverOutterBorderBrush}"/>
        <Setter Property="BorderBrush" TargetName="hoverBorderInner" Value="{DynamicResource CaptionButtonCloseHoverInnerBorderBrush}"/>
        <Setter Property="Background" TargetName="hoverBorderInner" Value="{DynamicResource CaptionButtonCloseHoverInnerBackgroundBrush}"/>

        <Setter Property="BorderBrush" TargetName="pressedBorder" Value="{DynamicResource CaptionButtonClosePressedOutterBorderBrush}"/>
        <Setter Property="BorderBrush" TargetName="pressedBorderInner" Value="{DynamicResource CaptionButtonClosePressedInnerBorderBrush}"/>
        <Setter Property="Background" TargetName="pressedBorderInner" Value="{DynamicResource CaptionButtonClosePressedInnerBackgroundBrush}"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

    <Style TargetType="{x:Type Fluent:WindowCommands}">
        <Setter Property="Foreground"
                Value="White" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Fluent:WindowCommands">
                    <ControlTemplate.Resources>
                        <ResourceDictionary>
                            <Style TargetType="{x:Type Button}">
                                <Setter Property="Background"
                                        Value="#02FFFFFF" />
                                <Setter Property="HorizontalContentAlignment"
                                        Value="Center" />
                                <Setter Property="VerticalContentAlignment"
                                        Value="Center" />
                                <Setter Property="Padding"
                                        Value="1" />
                                <Setter Property="Template"
                                        Value="{DynamicResource WindowCommandsControlTemplate}" />
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ShowTitleBar, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:RibbonWindow}}}"
                                                 Value="True">
                                        <Setter Property="Foreground"
                                                Value="White" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </ResourceDictionary>
                    </ControlTemplate.Resources>

                    <StackPanel Orientation="Horizontal"
                                VerticalAlignment="Top">
                        <ItemsControl ItemsSource="{Binding Items, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:WindowCommands}}}"
                                      ItemTemplate="{TemplateBinding ItemTemplate}"
                                      ItemTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                      ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                                      ItemContainerStyleSelector="{TemplateBinding ItemContainerStyleSelector}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal" />
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                        </ItemsControl>
                        <Button x:Name="PART_Min"
                                Style="{DynamicResource CaptionButtonStyle}"
                                Width="35"
                                Height="19"
                                BorderThickness="1,0,0,1"
                                ToolTip="{Binding Minimize, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:WindowCommands}}}"
                                Uid="{Binding Minimize, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:WindowCommands}}}">
                            <Image Width="Auto"
                                   Height="Auto"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Stretch="None"
                                   Source="{DynamicResource ImageCaptionButtonMinimize}"
                                   SnapsToDevicePixels="True" />
                        </Button>
                        <Button x:Name="PART_Max"
                                Margin="-1,0,0,0"
                                Style="{DynamicResource CaptionButtonStyle}"
                                Width="35"
                                Height="19"
                                BorderThickness="0,0,0,1"
                                ToolTip="{Binding Maximize, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:WindowCommands}}}"
                                Uid="{Binding Maximize, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:WindowCommands}}}">
                            <Grid>
                                <Image x:Name="PART_MaximizeButtonContent"
                                       Width="Auto"
                                       Height="Auto"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       Stretch="None"
                                       Source="{DynamicResource ImageCaptionButtonMaximize}"
                                       SnapsToDevicePixels="True" />
                                <Image x:Name="PART_RestoreButtonContent"
                                       Width="Auto"
                                       Height="Auto"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       Stretch="None"
                                       Source="{DynamicResource ImageCaptionButtonNormalize}"
                                       SnapsToDevicePixels="True" />
                            </Grid>
                        </Button>
                        <Button x:Name="PART_Close"
                                Margin="-1,0,0,0"
                                Style="{DynamicResource CaptionButtonStyle}"
                                Width="35"
                                Height="19"
                                BorderThickness="0,0,1,1"
                                Background="Red"
                                ToolTip="{Binding Close, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:WindowCommands}}}"
                                Uid="{Binding Close, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:WindowCommands}}}">
                            <Image Width="Auto"
                                   Height="Auto"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Stretch="None"
                                   Source="{DynamicResource ImageCaptionButtonClose}"
                                   SnapsToDevicePixels="True" />
                        </Button>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding ResizeMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
                                     Value="NoResize">
                            <Setter Property="Visibility"
                                    TargetName="PART_Min"
                                    Value="Collapsed" />
                            <Setter Property="Visibility"
                                    TargetName="PART_Max"
                                    Value="Collapsed" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ResizeMode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
                                     Value="CanMinimize">
                            <Setter Property="Visibility"
                                    TargetName="PART_Max"
                                    Value="Collapsed" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate TargetType="{x:Type Button}"
                     x:Key="WindowCommandsControlTemplate">
        <Grid Background="{TemplateBinding Background}">
            <ContentPresenter x:Name="contentPresenter"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              RecognizesAccessKey="True"
                              Opacity="0.75"
                              Margin="11,1,11,1" />

            <Rectangle x:Name="border"
                       SnapsToDevicePixels="True"
                       IsHitTestVisible="False"
                       Opacity="0.25"
                       Width="0"
                       Height="15"
                       VerticalAlignment="Stretch"
                       HorizontalAlignment="Right"
                       Fill="{TemplateBinding Foreground}"
                       Margin="10,0,0,0" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver"
                     Value="True">
                <Setter TargetName="contentPresenter"
                        Property="Opacity"
                        Value="1" />
            </Trigger>
            <Trigger Property="IsMouseOver"
                     Value="False">
                <Setter TargetName="contentPresenter"
                        Property="Opacity"
                        Value=".5" />
            </Trigger>
            <Trigger Property="IsKeyboardFocused"
                     Value="true" />
            <Trigger Property="ToggleButton.IsChecked"
                     Value="true" />
            <Trigger Property="IsEnabled"
                     Value="false">
                <Setter Property="Foreground"
                        Value="#ADADAD" />
            </Trigger>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource PreviousData}}"
                         Value="{x:Null}">
                <Setter TargetName="border"
                        Property="Rectangle.Width"
                        Value="1" />
            </DataTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>    
    
    <Style x:Key="RibbonWindowStyle"
           TargetType="{x:Type Fluent:RibbonWindow}">
        <Setter Property="GlassBorderThickness"
                Value="8,50,8,8" />
        <Setter Property="ResizeBorderThickness"
                Value="8" />
        <Setter Property="BorderThickness"
                Value="0" />        
        <Setter Property="CornerRadius"
                Value="15" />
        <Setter Property="CaptionHeight"
                Value="50" />
        <Setter Property="Foreground"
                Value="#FF000000" />
        <Setter Property="Background"
                Value="{DynamicResource WindowBackgroundBrush}" />
        <Setter Property="Behaviours:StylizedBehaviors.Behaviors">
            <Setter.Value>
                <Behaviours:StylizedBehaviorCollection>
                    <Behaviours:WindowsSettingBehavior />
                </Behaviours:StylizedBehaviorCollection>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsCollapsed"
                             Value="True" />
                    <Condition Property="CanUseDwm"
                               Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="GlassBorderThickness"
                        Value="8,30,8,8" />
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="WindowState"
                               Value="Maximized" />
                    <Condition Property="CanUseDwm"
                               Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="GlassBorderThickness"
                        Value="0,50,0,0" />                
            </MultiTrigger>
            <Trigger Property="WindowState"
                    Value="Maximized">
                <Setter Property="ResizeBorderThickness"
                        Value="0" />
            </Trigger>
            <Trigger Property="CanUseDwm"
                     Value="False">
                <Setter Property="Template"
                        Value="{DynamicResource NonDwmRibbonWindowControlTemplate}" />
                <!-- Cheat with GlassBorderThickness. We have to set something else than 0 to avoid some bugs in the WindowChrome class. -->
                <Setter Property="GlassBorderThickness"
                        Value="0,0,0,1" />
            </Trigger>
            <Trigger Property="CanUseDwm"
                     Value="True">
                <Setter Property="Template"
                        Value="{DynamicResource DwmRibbonWindowControlTemplate}" />
            </Trigger>
        </Style.Triggers>
    </Style>    
</ResourceDictionary>